package com.iqiyi.pps.epg.web.utils;

import com.iqiyi.kiwi.utils.ServletUtils;
import org.apache.commons.lang.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-12-12
 * Time: 下午12:11
 * To change this template use File | Settings | File Templates.
 */
public class SearchUtils {
    /**
     * 从request中构建search参数
     */
    public static Map<String,Object> getSearchParamFromRequest(){
        Map<String, Object> filterParamMap = ServletUtils.getParametersStartingWith(Struts2Utils.getRequest(), "filter_");
        Map<String,Object> filterMap = new HashMap<String, Object>();
        for (Map.Entry<String, Object> entry : filterParamMap.entrySet()) {
            String filterName = entry.getKey();
            String value = (String) entry.getValue();
            if (StringUtils.isNotBlank(value)) {
                filterMap.put(filterName, value.trim());
            }
        }
        return filterMap;
    }
}
